<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
          函数是可以相互调用的
        */
        //    买土豆
        let shopping=prompt('想吃土豆、西红柿还是鸡蛋')
        function buy(shopping) {
            console.log('去超市');
            if (shopping == '土豆') {
                console.log('挑选土豆');
                shopping = '土豆';
            } else if (shopping == '西红柿') {
                console.log('挑选西红柿');
                shopping = '西红柿';
            } else {
                console.log('挑选鸡蛋');
                shopping = '鸡蛋';
            }
            return shopping;
        }
        //  土豆炖牛腩
        function beff() {
            console.log('切' + buy(shopping));
            console.log('切牛肉');
            console.log('炒菜');
            console.log('土豆牛腩做好啦');
        }
        // 西红柿炒鸡蛋
        function tomato() {
            console.log('炒' + buy(shopping));
            console.log('西红柿鸡蛋炒好啦');
        }
        if(shopping=='土豆'){
            beff();
        }else if(shopping=='西红柿'||'鸡蛋'){
             tomato();
        }
       
        
    </script>
</body>

</html>